package com.lzh.controller;

import com.lzh.pojo.resp.NoticeStatic;
import com.lzh.utils.UploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

/**
 * @author Li
 * @ 2022/3/29
 */
@RestController
@RequestMapping("/thymeleaf")
public class ThymeleafController {

    @Autowired
    UploadUtils uploadUtils ;
    @Autowired
    TemplateEngine templateEngine ;
    @RequestMapping("/model")
    public String test(@RequestBody NoticeStatic noticeStatic){
        Context context = new Context();
        context.setVariable("title" , noticeStatic.getTitle()) ;
        context.setVariable("context" , noticeStatic.getContext()) ;
        String template = templateEngine.process("Template", context);

        String s = uploadUtils.uploadHtml(template);

        return s ;
    }
}
